package cn.edu.zust.se.mapper.anno;

import cn.edu.zust.se.model.User;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Set;

/**
 * 
 * @author czg
 * @since 2022/11/9 10:36
 */

public interface UserMapper {
    @Results(id="userMap",value = {
            @Result(property = "id",column = "id"),
            @Result(property = "name",column = "name"),
            @Result(property = "password",column = "password"),
            @Result(property = "email",column = "email"),
            @Result(property = "mobile",column = "mobile"),
            @Result(property = "cards",javaType = Set.class,column = "id",
            many = @Many(select = "cn.edu.zust.se.mapper.anno.CreditCardMapper.getCardsByUser"))

    })
    @Select("select * from t_user where id=#{userId}")
    public User getUserById(int userId);

    @Select("select * from t_user where id=#{userId}")
    @ResultMap(value = "userMap")
    public User getUserById2(int uid);
}
